<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            height: 100vh;
            display: flex;

        }

        canvas {
            margin: auto;
            border: thin inset #ccc;
        }
    </style>
</head>

<body>
    <canvas id="canvas" width="800" height="600"></canvas>
    <script>
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');
        ctx.font = '24px Helvetica'
        ctx.lineJoin = 'round';
        ctx.lineWidth = 30
        ctx.strokeStyle = 'blue'
        ctx.fillStyle = 'rgba(0,0,0,.5)'
        ctx.fillText('Click anywhere to erase', 200, 200)
        ctx.strokeRect(75, 100, 200, 200)
        ctx.fillRect(300, 100, 200, 200)

        canvas.onclick = function () {
            ctx.clearRect(0, 0, canvas.width, canvas.height)
        }
    </script>
</body>

</html>